#!/usr/bin/env python
# -*- coding:utf-8 -*-
import functools


def log(func):
    @functools.wraps(func)
    def wrapper(*args, **kw):
        print 'call %s():' % func.__name__
        return func(*args, **kw)

    return wrapper


def log(text):  # 带参数的装饰器
    def decorator(func):
        @functools.wraps(func)
        def wrapper(*args, **kw):
            print '%s %s():' % (text, func.__name__)
            return func(*args, **kw)

        return wrapper

    return decorator


@log('excute')
def now():
    print "hello world"


if __name__ == '__main__':
    now()
    log('execute')(now)
    print now.__name__   # now 与 wrapper ， @functools.wraps(func)